package com.ys.data.api.config;

import com.common.util.DingDingUtils;
import com.ys.data.api.async.AsyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

/**
* @version: V1.0
* @author: szw
* @className: DataInit
* @packageName: DataInit
* @description: 统一管理异步执行任务
* @date: 2021-1-19
**/
@Component
@Slf4j
public class DataInit implements CommandLineRunner {

    @Resource
    private AsyncService asyncService;

    @Override
    public void run(String... args) throws Exception {
        log.info("CommandLineRunner 初始化开始");
        try {
            //初始化role数据
            asyncService.initRoleDataResult();
            //初始化字典
            asyncService.initDictData();
            //初始化排行榜
            asyncService.leaderboard();
        }catch (Exception e){
            log.error("CommandLineRunner 初始化异常",e);
            DingDingUtils.sendTextToDD("警告：Api服务初始化信息异常，异常信息"+e.getMessage());
        }
        log.info("CommandLineRunner 初始化结束");
    }



}
